package com.gitee.andy.NettyRpcClientSample;

import java.util.concurrent.ThreadLocalRandom;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.gitee.andy.NettyRpcApiSample.CalcService;
import com.gitee.andy.rpc.client.RpcClient;

public class ClientStart {

	private static final Logger log = LoggerFactory.getLogger(ClientStart.class);

	public static void main(String[] args) {
		try (ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
				"spring.xml")) {
			RpcClient rpcClient = classPathXmlApplicationContext.getBean(RpcClient.class);
			for (int i = 0; i < 10; i++) {
				int a = ThreadLocalRandom.current().nextInt(10000);
				int b = ThreadLocalRandom.current().nextInt(10000);
				log.info("{}, {}", a + b, rpcClient.get(CalcService.class).add(a, b));
			}
			rpcClient.shutdown();
		}
	}
}
